<template>
	<!-- 我的康复师 -->
	<view style="		
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;">
		<my-card style="z-index: 999;" :title1="teacherName" title2="康复师" title3="我的客户" :title4="memberCount" title5="../static/logo.png"></my-card>
		<view style="		
			width: 641rpx;
			height: 341rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 11rpx 14rpx 0rpx #E9F7ED;
			border-radius: 29rpx;
			padding: 38rpx 33rpx;
			display: flex;
			flex-direction: column;
			justify-content: flex-end;
			margin-top: -120rpx;">
			<my-task :list="list" :num="num"></my-task>
		</view>
		<view style="		
			width: 100vw;
			background: #fff;
			box-shadow: 0rpx 11rpx 14rpx 0rpx #E9F7ED;
			border-radius: 45rpx 45rpx 0rpx 0rpx;
			margin-top: 25rpx;
			box-sizing: border-box;
			padding: 30rpx 24rpx;">
			<my-class></my-class>
		</view>
	</view>
</template>

<script>
	import myCard from "@/components/my-card.vue"
	import myTask from "@/components/my-task.vue"
	import myClass from "@/components/my-class.vue"
	export default {
		name: "myRehabilitation",
		components: {
			myCard,
			myTask,
			myClass
		},
		data() {
			return {
				num: 0,
				teacherName: "",
				memberCount: "",
				list: [{
						icon: "/static/icon/all.png",
						name: "全部",
						num: 0
					}, {
						icon: "/static/icon/waitClass.png",
						name: "待上课",
						num: 0
					},
					{
						icon: "/static/icon/completed.png",
						name: "已完成",
						num: 0
					}
				]
			}
		},
		onLoad() {

		},
		mounted() {
			this.teacherDetail();
			this.teacherMemberCount();
			this.teacherClassCount();
		},
		methods: {
			reLoadFn() {
				//刷新数据逻辑
				this.teacherDetail();
				this.teacherMemberCount();
				this.teacherClassCount();
			},
			teacherDetail() {
				let that = this;
				uni.request({
					url: "https://guokang365.mordo-care.com/api/recureTeacher/find/" + getApp().globalData.recureTeacherId,
					method: 'GET',
					//仅为示例，并非真实接口地址。
					header: {
						'Cookie': "JSESSIONID=" + getApp().globalData.serverSession
					},
					success: (res) => {
						if (res.data.result != '100') {
							// 获取会员详情失败，不确定是否要弹窗
						} else {
							that.teacherName = res.data.entity.name;
							getApp().globalData.teacherName = res.data.entity.name;
						}
					},
				});
			},
			teacherMemberCount() {
				let that = this;
				uni.request({
					url: "https://guokang365.mordo-care.com/api/custom/countMemberNumByRecureTeacherId/" + getApp().globalData.recureTeacherId,
					method: 'GET',
					//仅为示例，并非真实接口地址。
					header: {
						'Cookie': "JSESSIONID=" + getApp().globalData.serverSession
					},
					success: (res) => {
						if (res.data.result != '100') {
							// 获取会员统计数据失败，不确定是否要弹窗
						} else {
							const memberCount = res.data.memberNum + "人";
							that.memberCount = memberCount;
						}
					},
				});
			},
			teacherClassCount() {
				let that = this;
				uni.request({
					url: "https://guokang365.mordo-care.com/api/custom/countLessonNumByRecureTeacherId/" + getApp().globalData.recureTeacherId,
					method: 'GET',
					//仅为示例，并非真实接口地址。
					header: {
						'Cookie': "JSESSIONID=" + getApp().globalData.serverSession
						// 'JSESSIONID': getApp().globalData.serverSession //自定义请求头信息
					},
					success: (res) => {
						if (res.data.result != '100') {
							// 获取会员统计数据失败，不确定是否要弹窗
						} else {
							let countData = res.data;
							let list2 = that.list;
							list2[0].num = countData.totalNum;
							list2[1].num = countData.toBeCompletedNum;
							list2[2].num = countData.finishedNum;
							that.list = list2
						}
					},
				});
			},
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.task-card {
		width: 641rpx;
		height: 341rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 11rpx 14rpx 0rpx #E9F7ED;
		border-radius: 29rpx;
		padding: 38rpx 33rpx;
		display: flex;
		flex-direction: column;
		justify-content: flex-end;
		margin-top: -120rpx;
	}

	.class-card {
		width: 100vw;
		background: #fff;
		box-shadow: 0rpx 11rpx 14rpx 0rpx #E9F7ED;
		border-radius: 45rpx 45rpx 0rpx 0rpx;
		margin-top: 25rpx;
		box-sizing: border-box;
		padding: 30rpx 24rpx;

	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>